package com.example.demo13.controllers;

import com.example.demo13.model.Dialog;
import com.example.demo13.service.DialogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DialogController {
    @Autowired
    private DialogService dialogService;
   @RequestMapping("/chaxun")
    public @ResponseBody Object chaxun( Integer id){
       Dialog dialog= dialogService.queryDialogById(id);
       return  dialog;

   }

   @RequestMapping("xiugai")
    public @ResponseBody Object xiugai(Integer id,String peo_txt){
       Dialog dialog=new Dialog();
       dialog.setId(id);
       dialog.setPeoTxt(peo_txt);
       int updateCount=dialogService.updateDialogById(dialog);
       return  id+"/"+updateCount;
   }
   @RequestMapping("shanchu")
    public @ResponseBody Object shanchu(Integer id){
       Dialog dialog=new Dialog();

       String i=dialogService.deleteDialogById(id);
       return  i;
   }
   @RequestMapping("/ceng")
    public @ResponseBody Object ceng( String session_id,String peo_id,String peo_txt){
       Dialog dialog=new Dialog();
       dialog.setSessionId(session_id);
       dialog.setPeoId(peo_id);
       dialog.setPeoTxt(peo_txt);
       int cengCount=dialogService.insertDialog(dialog);
       return cengCount;

   }
}
